<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生信息管理系统</title>
    <link rel="stylesheet" href="styles.css">
</head>
<style>
    /* 重置默认样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 设置字体和背景色 */
body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
}

/* 头部样式 */
header {
    background-color: #4CAF50;
    color: white;
    padding: 1rem;
    text-align: center;
}

/* 导航栏样式 */
nav {
    background-color: #333;
    padding: 1rem;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
}

nav ul li {
    margin: 0 1rem;
}

nav ul li a {
    color: white;
    text-decoration: none;
}

nav ul li a:hover {
    color: #4CAF50;
}

/* 主要内容区样式 */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    background-color: white;
    padding: 2rem;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 0.5rem;
    border: 1px solid #ddd;
    text-align: left;
}

table th {
    background-color: #f8f8f8;
}

table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 页脚样式 */
footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
}
</style>
<body>
    <header>
        <h1>学生信息管理系统</h1>
    </header>
    <nav>
        <ul>
            <li><a href="students.html">学生管理</a></li>
            <li><a href="courses.html">课程管理</a></li>
            <li><a href="grades.html">成绩管理</a></li>
        </ul>
    </nav>
    <main>
        <section>
            <h2>学生列表</h2>
            <table>
                <thead>
                    <tr>
                        <th>学号</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                    </tr>
                </thead>
                <tbody id="studentList">
                    <!-- 学生数据将通过JavaScript动态加载 -->
                </tbody>
            </table>
        </section>
    </main>
    <footer>
        <p>&copy; 2023 学生信息管理系统</p>
    </footer>
    <script src="script.js"></script>
</body>
<script>
    // 模拟学生数据
const students = [
    { StudentId: 1, StudentName: "张三", Age: 20, Gender: "男" },
    { StudentId: 2, StudentName: "李四", Age: 22, Gender: "女" },
    { StudentId: 3, StudentName: "王五", Age: 21, Gender: "男" }
];

// 动态加载学生数据到表格
function loadStudents() {
    const studentList = document.getElementById("studentList");
    studentList.innerHTML = "";

    students.forEach(student => {
        const row = document.createElement("tr");
        row.innerHTML = `
            <td>${student.StudentId}</td>
            <td>${student.StudentName}</td>
            <td>${student.Age}</td>
            <td>${student.Gender}</td>
        `;
        studentList.appendChild(row);
    });
}

// 页面加载完成后执行
window.addEventListener("load", loadStudents);

// 处理用户交互事件
document.addEventListener("DOMContentLoaded", function() {
    const studentList = document.getElementById("studentList");

    studentList.addEventListener("click", function(e) {
        if (e.target.tagName === "TD") {
            const studentId = e.target.parentNode.cells[0].textContent;
            alert(`你点击了学号为${studentId}的学生`);
        }
    });
});
</script>
</html>